
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>要素入れ替え</title>
<link href="../jQuery/css/jquery-ui.css" rel="stylesheet" type="text/css" />
<style type="text/css">
#sortable1,#sortable2 {
	list-style-type: none;
	margin: 0;
	padding: 0;
	float: left;
	margin-right: 10px;
}

#sortable1 li,#sortable2 li {
	margin: 0 5px 5px 5px;
	padding: 5px;
	font-size: 1.2em;
	width: 120px;
}
</style>

<script src="../jQuery/js/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="../jQuery/js/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>
<script type="text/javascript">
	var option = {
		stop : function() {
			var data = [];
			$("tr td.key", "#sortable tbody").each(function(i, v) {
				data.push(v.innerHTML);
			});
			$('#viewSortlist').html(data.toString()).css("background-color", "#eee");
		}
	};
	$(function() {
		$("#sortable tbody").sortable(option);
		$("#sortable tbody").disableSelection();
	});
</script>
</head>
<body>
	<h2>要素入れ替え（テーブル）</h2>
	<p>D&amp;Dで要素の移動</p>

	<table id="sortable">
		<tr><th>0</th><th>位置変わらない</th></tr>
		<tbody>
			<tr><td class="key">1</td><td>AAA</td></tr>
			<tr><td class="key">2</td><td>BBB</td></tr>
			<tr><td class="key">3</td><td>CCC</td></tr>
			<tr><td class="key">4</td><td>DDD</td></tr>
		</tbody>
	</table>
	
	<br />
	
	<div id="viewSortlist">ここへ並べ替えた順番を出力します</div>

</body>
</html>
<!-- see:http://jsajax.com/Articles/jQueryUISortableConnectList/1287 -->